package com.design.过滤器模式;

import java.util.ArrayList;
import java.util.List;

public class TestMain {

	public static void main(String[] args) {

		User z = new User(2, "zhangsan");
		User x = new User(3, "wanger");

		List<User> users = new ArrayList<User>();
		users.add(x);
		users.add(z);

		Filter broadbandFilter = new BroadbandFilter();
		Filter freeFlowFilter = new FreeFlowFilter();

		System.out.println("broadbandFirter:");
		printUsers(broadbandFilter.filtrate(users));

		System.out.println("freeFlowFilter:");
		printUsers(freeFlowFilter.filtrate(users));

for (int i = 0; i <= 4; i++) {
	for (int n = 4 - i; n >= 0; n--) {
		System.out.print(" ");
	}
	for (int n = 1; n <= (i * 2) + 1; n++) {
		if(n == 1 || n == (i * 2) + 1) {
			System.out.print("*");
		}else {
			System.out.print(" ");
		}
	}
	System.out.println();
}

for (int i = 3; i >= 0; i--) {
	for (int n = 4 - i; n >= 0; n--) {
		System.out.print(" ");
	}
	for (int n = 1; n <= (i * 2) + 1; n++) {
		if( n == 1 || n == (i * 2) + 1) {
			System.out.print("*");
		}else {
			System.out.print(" ");
		}
	}
	System.out.println();
}
	}

	public static void printUsers(List<User> users) {
		users.forEach(e -> {
			System.out.println(e.getId() + "--" + e.getUsername());
		});
	}

}
